#ifndef _DEBUG_PRINT_H_
#define _DEBUG_PRINT_H_

#define _DEBUG
/************************************  copyright (c) 2018 ZhangBing **********************************************************/
/*-----------------------------------------------------------------------------------------------------------------------------
|	eg: DEBUG_PRINT("hello\r\n")                                                                                              |
|	    [2018-09-18 09:28:56] [1016]       [1018]      [CameraDisplay.cpp:  179]  (RTSP_Construct) --->hello              |
|	    [time]                [process id] [thread id] [source filename  : line]  (function name)  --->output content     |
------------------------------------------------------------------------------------------------------------------------------*/
#ifdef _DEBUG            //debug
#ifndef  DEBUG_PRINT
#ifdef   WIN32    
#define  LOG_FILE_NAME "" //"C:\\log.txt"  //win32存放的文件名
#else
#define  LOG_FILE_NAME "" //"/mnt/data/log.txt"   //linux存放的文件名
#endif
#include <stdio.h>
#include <time.h>
#ifdef   WIN32
#include "windows.h"
#define  _debug_get_thread_id__  GetCurrentThreadId()
#define  _debug_get_process_id__ GetCurrentProcessId()
#else
#include <unistd.h>
#include <sys/syscall.h>
#define  _debug_get_thread_id__ syscall(__NR_gettid)
#define  _debug_get_process_id__ getpid()
#endif
#define  DEBUG_PRINT(...) {time_t _debug_now__ = time(NULL);char _debug_buf__[25]={0};char _debug_out__[256]={0};strftime(_debug_buf__,24,"%Y-%m-%d %H:%M:%S",localtime(&_debug_now__));sprintf(_debug_out__,("[%17s] [%10d] [%10d] [%20s:%5d] (%25s) --->"),_debug_buf__,_debug_get_process_id__,_debug_get_thread_id__,__FILE__,__LINE__, __FUNCTION__);fprintf(stderr,"%s",_debug_out__);fprintf(stderr,__VA_ARGS__);{FILE *_debug_fp__;_debug_fp__=fopen(LOG_FILE_NAME,"a+");if(_debug_fp__!=NULL){fprintf(_debug_fp__,"%s",_debug_out__);fprintf(_debug_fp__,__VA_ARGS__);fclose(_debug_fp__);}}}
#endif
#else                  //release
#define  DEBUG_PRINT(...) printf(__VA_ARGS__);
#endif
/********************************************************************************************************************************/
#endif
